package IViews;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;

public class IMessageBox extends JPanel {
	
	private IImageWraper[] border;
	private final JPanel content;
	
	public IMessageBox(int x, int y, int width, int height, String pText) {
		border = new IImageWraper[8];
		this.setBounds(x, y, width, height);
		this.setOpaque(false);
		this.setLayout(null);

		border[0] = new IImageWraper(0, 0, 11, 11, "Borders/corner_0.png");
		border[1] = new IImageWraper(11, 0, width - 22, 11,
				"Borders/border_1.png");
		border[2] = new IImageWraper(width - 11, 0, 11, 11,
				"Borders/corner_1.png");
		border[3] = new IImageWraper(width - 11, 11, 11, 1,
				"Borders/border_2.png");
		border[4] = new IImageWraper(width - 11, 12, 11, 11,
				"Borders/corner_2.png");
		border[5] = new IImageWraper(11, 12, width - 22, 11,
				"Borders/border_3.png");
		border[6] = new IImageWraper(0, 12, 11, 11, "Borders/corner_3.png");
		border[7] = new IImageWraper(0, 11, 11, 1, "Borders/border_0.png");
		for (int i = 0; i < border.length; i++) {
			if (border[i] != null) {
				this.add(border[i]);
			}
		}

		this.content = new JPanel();
		content.setLayout(null);
		content.setBounds(11, 11, width - 22, 1);
		content.setBackground(Color.WHITE);
		this.add(content);
		
		border[3].changeMyImageIcon(11, this.getHeight() - 22);
		border[4].setLocation(width - 11, this.getHeight() - 11);
		border[5].setLocation(11, this.getHeight() - 11);
		border[6].setLocation(0, this.getHeight() - 11);
		border[7].changeMyImageIcon(11, this.getHeight() - 22);
		content.setSize(width - 22, this.getHeight() - 22);
		
		JTextPane jl = new JTextPane();
		jl.setText(pText);
		jl.setEditable(false);
		jl.setBounds(11, 11, width-22, height-22);
		jl.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
		jl.setBackground(Color.WHITE);
		this.add(jl,0);
	}
}
